<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>
	   	<f:viewParam name="rosterId" value="#{undeterminedRosterHome.id}"></f:viewParam>
	  	<f:event listener="#{undeterminedRosterHome.initConversation()}" type="preRenderView"></f:event>
	   	<f:event listener="#{serviceSupplierManageList.setMaxResults(null)}" type="preRenderView"></f:event>
	   	<f:viewParam name="moduleName" value="待定名单管理"></f:viewParam>
   	</f:metadata>
   
    <ui:define name="head">
    	<style type="text/css">
    		ul.ui-autocomplete-multiple-container {
    			width: 600px;
    		}
    	</style>
    </ui:define>
   
   	<ui:define name="content">
   
		<h:form id="editForm">         
			<p:panel id="panel" header="#{undeterminedRosterHome.managed ? '修改' : '新增'}待定名单" style="margin-bottom:10px;">
		        <p:messages id="messages" closable="true"><p:autoUpdate/></p:messages>
		        
		        <h:panelGrid columns="2" cellpadding="5">
					<p:outputLabel for="suppliers" value="选择中介机构" />
					<ui:remove>
						<p:selectCheckboxMenu id="suppliers"
							required="true"
							style="width:300px;"
							value="#{undeterminedRosterHome.instance.suppliers}" filter="true"
							filterMatchMode="contains" panelStyle="width:250px">
							
							<f:attribute name="collectionType" value="java.util.ArrayList" />
							<f:selectItems value="#{serviceSupplierManageList.resultList}"
								var="_supplier" itemLabel="#{_supplier.cnname}" itemValue="#{_supplier}" />
							<f:converter converterId="entityConverter"></f:converter>
							<f:ajax event="change" render="editForm:selectedsuppliers"></f:ajax>	
					    </p:selectCheckboxMenu>
					 </ui:remove>  
			        <p:autoComplete id="suppliers" multiple="true" value="#{undeterminedRosterHome.selectedSuppliers}" completeMethod="#{undeterminedRosterHome.filterSupplier}"
			                        var="_supplier" itemLabel="#{_supplier.cnname}" itemValue="#{_supplier}" required="true" converter="entityConverter" forceSelection="true"
			                        placeholder="请输入中介名称">		            
			            <p:column>
			                <h:outputText value="#{_supplier.cnname}" />
			            </p:column>
			        </p:autoComplete>
						   
				    <p:outputLabel for="startDate" value="列入待定名单期限始" />
				    <p:calendar
								id="startDate"
								value="#{undeterminedRosterHome.instance.startDate}"
								required="true"
								navigator="true"
								locale="zh_CN"
								showOn="button"
								pattern="yyyy-MM-dd"
								inputStyleClass="input-middle" 
							/>				
					<p:outputLabel for="endDate" value="列入待定名单期限止" />
				    <p:calendar
								id="endDate"
								value="#{undeterminedRosterHome.instance.endDate}"
								required="true"
								navigator="true"
								locale="zh_CN"
								showOn="button"
								pattern="yyyy-MM-dd"
								inputStyleClass="input-middle" 
							/>	
					
					<p:outputLabel for="evidences" value="证据材料" />		
					<p:outputPanel id="evidences">
						<p:fileUpload
							id="attachmentUploadFile"
							label="选择"
							mode="advanced"
							required="true"
							multiple="true"
							skinSimple="true"
							sizeLimit="#{1024 * 1024 * 3}"
							uploadLabel="上传"
							cancelLabel="取消"
							update="editForm:uploadedEvidences"
							fileUploadListener="#{undeterminedRosterHome.uploadEvidence}"
						/>
						<p:panel id="uploadedEvidences">
							<ul>
								<p:repeat var="_attachment" value="#{undeterminedRosterHome.instance.evidences}">
									<li>
										<h:outputText value="#{_attachment.filename}" />
										<span>
											<p:commandLink style="margin-left:5px;" action="#{undeterminedRosterHome.removeEvidence(_attachment)}" update="editForm:uploadedEvidences" immediate="true" >×</p:commandLink>
										</span>
									</li>
								</p:repeat>
							</ul>
						</p:panel>
					</p:outputPanel>								
					
					<p:outputLabel for="remarks">备注</p:outputLabel>
					<p:inputTextarea id="remarks"
									value="#{undeterminedRosterHome.instance.remark}"
									cols="80"
									rows="5">					
					</p:inputTextarea>
				</h:panelGrid>
			</p:panel>
			
			<p:commandButton action="#{undeterminedRosterHome.saveAndFlush()}" value="保存" ajax="false" />
			
			<p:commandButton value="删除" action="#{undeterminedRosterHome.delete()}">
				<p:confirm header="请确认" message="您确认删除记录吗?" icon="ui-icon-alert" />
			</p:commandButton>
			<p:commandButton action="#{undeterminedRosterHome.cancel()}" value="取消" immediate="true"></p:commandButton>	
						
			<p:confirmDialog id="confirmDialog" global="true" showEffect="fade" hideEffect="explode" widgetVar="confirmDialog">
			    <p:commandButton value="确认" styleClass="ui-confirmdialog-yes"></p:commandButton>
			    <p:commandButton value="取消" immediate="true" styleClass="ui-confirmdialog-no" />
			</p:confirmDialog>
		</h:form>
   	</ui:define>
</ui:composition>
